package lspUtils;


import java.io.Closeable;
import java.io.IOException;
import java.net.InetAddress;
import java.net.SocketException;

public class LspConnection implements Closeable {
	private InetAddress address;
	private int port;
	private short id; 
	private LspParams lspParams;
	
	public LspConnection(InetAddress address, int port, short id, LspParams lspParams) throws SocketException {
		
		this.address= address;
		this.port = port;
		this.lspParams = lspParams;
		
		setConnectionId(id);
		
		startServices();
		sendAckToClient();
	}
	
	private void sendAckToClient() {
		LspPacket lspPacket = new LspPacket(MessageType.ACK, getConnectionId(), (short) 0);
		sendPacket(lspPacket);
	}

	public void sendData(byte[] payload) {
		LspPack pack = new LspPack(getConnectionId(), payload);
		lspSender.sendData(pack);
	}

	
	public void addReceivedExternalPack(LspPack pack) {
		receivedPack.add(pack);
	}

	
	public void close() throws IOException {
		// TODO Auto-generated method stub
		
	}
}